<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="${article.title}" />
    <meta name="keywords" content="${article.title}" />
    <meta name="title" content="${article.title}">
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <![endif]-->
    <title>${article.title}</title>
    <link href="/css/font-awesome/css/font-awesome.min.css" rel="stylesheet" id="theme-styles">
    <#include "../include.ftl">
</head>
<body>
<#include "../header.ftl">

<section  >
    <div class="container">
        <div class="row">
            <div class="col-md-9" style="background-color: #FFFFFF">
                <div class="blog-main">
                    <div class="heading-blog">
                        ${article.title}
                    </div>
                    <div class="blog-info">
                        <span>作者：${article.userName}</span>
                        &nbsp;
                        <span>
                                阅读：${article.viewcount}
                        </span>
                        &nbsp;
                        <span >${article.createtime}</span>
                    </div>
                    <div class="blog-txt">
                    ${article.content}
                    </div>
                </div>
                <#if (loginUser.username)??>
                    <div class="form-group">
                        <label for="name">回复</label>
                        <textarea class="form-control" rows="3" id="content" name="content" placeholder="回复您的看法"></textarea>
                        <div class="alert alert-success" role="alert" id="loginTips" style="display: none"></div>
                        <br>
                        <button type="button" class="btn btn-outline-primary" id="contentSubmit" data-toggle="popover" data-placement="right" title="提示词">提交</button>
                    </div>

                <#else >
                    <div style="color: #909090;text-align: center">评论</div>
                    <div class="panel panel-default" style="background-color: #F8F9FA;">
                        <div class="panel-body" style="text-align: center;vertical-align: center">
                            <button type="button" id="loginBtn" class="btn btn-primary">登录</button>&nbsp;&nbsp;说说你的看法
                        </div>
                    </div>
                </#if>
                <span><strong>${commentCount!}条评论</strong> </span>
                <hr/>

                <!--BLOG MAIN SECTION END-->
                <ul class="media-list">
                    <#if comments??>
                    <div class="commentList">
                    <#list comments as l>
                    <li class="media">
                        <a class="pull-left" href="#">
                            <#if l.avatar?? && l.avatar !=''>
                               <img class="media-object img-circle"   src="${IMAGE_BASE_URL}${l.avatar}" style=" float: left;border-radius: 100px; width: 2.3rem;"/>
                            <#else>
                                <img src="/img/default_head.jpg" style="height: 1.9rem;float:left; border-radius: 50%; border: 3px solid #eee; overflow: hidden;">
                            </#if>
                        </a>
                        <div class="media-body">
                            <h7 class="media-heading">${l.username}</h7>
                            <p style="font-size: 2px;margin-bottom: 0.1rem">${l.createtime}</p>
                            <p style="margin-bottom: 0.1rem">
                                ${l.content}
                            </p>
                        </div>
                    </li>
                    <hr/>
                    </#list>
                    </div>
                     <a href="javascript:;" class="button button-block button-rounded button-large" id="more_art">更多</a>
                    </#if>

                </ul>
                <!--COMMENTS SECTION END-->
                <hr/>




            </div>
            <br>
            <#include "../right.ftl">


        </div>
    </div>
</section>
<input type="hidden" id="artid" value="${article.id}">
<#include "../footer.ftl">
<script src="/js/modernizr.js"></script>

<script src="/js/blog/detail_blog.js"></script>
<script>
    var tips = '没有啦~';
    var pageNo = 2;
    var artid = $('#artid').val();
    $('#more_art').click(function () {

        if(tips == $('#more_art').text()) {
            return;
        }
        $.ajax({
            url:"/comment/jsonList",
            type:"post",
            data:{pageNo:pageNo,artid:artid},
            success:function(data){
                if(data == null || data == '') {
                    $('#more_art').text(tips);
                }
                else {
                    var l = '';
                    $.each(data,function(index,item){
                        l += '<li class="media">\n' +
                                '                        <a class="pull-left" href="#">\n' +
                                '                            <img class="media-object img-circle"   src="/img/default-man.jpg" style=" float: left;border-radius: 100px; width: 45px;"/>\n' +
                                '                        </a>\n' +
                                '                        <div class="media-body">\n' +
                                '                            <h7 class="media-heading">'+item.username+'</h7>\n' +
                                '                            <p style="font-size: 2px">'+item.createtime+'</p>\n' +
                                '                            <p>\n' +
                                '                                '+item.content+'\n' +
                                '                            </p>\n' +
                                '                        </div>\n' +
                                '                    </li>\n' +
                                '                    <hr/>';
                    })
                    $('.commentList').append(l);
                    pageNo += 1;
                }

            }
        });
    })
</script>
</body>
</html>
